<%@ page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>

<head>
<title>GL WebGL BIM Engine</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="icon" href="${pageContext.request.contextPath}/Themes/default/Content/webimg/bimlogo.ico" type="img/x-ico" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/CSS/reset.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/Scripts/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/CSS/style_GL_WebGL_BIM_Engine.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/CSS/toolsbar.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Content/plugins/layer/skin/layer.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/CSS/simpletooltip.min.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/Scripts/pagewalkthrough/css/jquery.pagewalkthrough.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/CSS/colpick.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Content/plugins/JqueryLoading/loading.css" rel="stylesheet" />
<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/jquery.min.js"></script>
<link href="${pageContext.request.contextPath}/Content/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath}/Content/bootstrap/css/bootstrap.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Content/plugins/layer/skin/layer.css" rel="stylesheet" />
<link href="${pageContext.request.contextPath}/Themes/default/Content/CSS/bim_modelcss.css" rel="stylesheet" />
<!-- 右侧检测结果 -->
<style>
#tagIModelListForm .t_checkbox1 .check_slider1 {
	display: inline-block;
	width: 18px;
	height: 18px;
	background: #D7D9D9;
	border-radius: 18px;
	position: absolute;
	top: 5px;
	left: 24px;
	cursor: pointer;
}

#tagIModelListForm .t_checkbox1 .check_slider_hecked1 {
	background: #8FC5ED;
	left: 1px;
}

#tagIModelListForm .t_checkbox1 {
	width: 43px;
	height: 20px;
	vertical-align: middle;
	float: left;
	position: relative;
}

#tagIModelListForm .t_checkbox1::before {
	content: "";
	display: inline-block;
	width: 43px;
	height: 20px;
	background: #FEFFFF;
	vertical-align: middle;
	-webkit-border-radius: 20px;
	border-radius: 20px;
	-webkit-box-sizing: border-box;
	-webkit-transition: background ease-in .5s;
	cursor: pointer;
}

.line_div_bg {
	background: #d8dbe8;
}
.btn_tabs {
	width: 295px !important;
}

.pop_contents_tree .treeview span.tree_leave {
	display: inline-block !important;
	cursor: pointer !important;
	width: 60% !important;
	height: 30px !important;
	line-height: 30px !important;
	overflow: hidden !important;
	vertical-align: bottom !important;
	padding-right: 5px;
}

.pop_box_contents>div {
	width: 257px !important;
}

.pop_contents_type .treeview span.tree_leave {
	display: inline-block !important;
	cursor: pointer !important;
	width: 65% !important;
	height: 30px !important;
	line-height: 30px !important;
	overflow: hidden !important;
	vertical-align: bottom !important;
}
</style>
</head>

<body class="hold-transition skin-blue sidebar-mini fixed">
	<div style="position:absolute; width:200px; height:200px;left:100px;top:100px; border:1px solid gray; z-index:1000"  ><div>临时链接，查看其它模型</div>
	<a href="${pageContext.request.contextPath}/Home/index?MileageID=1">一层负一层楼梯组合</a><br/>
	<a href="${pageContext.request.contextPath}/Home/index?MileageID=2">中心医院A区</a><br/>
	<a href="${pageContext.request.contextPath}/Home/index?MileageID=3">房子示例</a><br/>
	<a href="${pageContext.request.contextPath}/Home/index?MileageID=4">楼梯</a><br/>
	<a href="${pageContext.request.contextPath}/Home/index?MileageID=5">负一层建筑</a><br/>
	<a href="${pageContext.request.contextPath}/Home/index?MileageID=6">一层结构</a></div>

	<div class="wrapper">
		<div id="content-wrapper">
			<div>
				<div class="wrapp_content" style="width: 100%; height: 500px;">
					<div id="webglContainer" class="map_contcanves" style="height: 500px; width: 100%;">
						<div id="webcanvas" style="position: absolute; width: 100%"></div>
					</div>
					<div class="btn_tabs" style="height: auto;">
						<!--左上角查看模型树结构属性按钮在此-->
						<input type="hidden" id="hid_tabs" value="0" />
						<div class="tabs_btn">
							<ul>
								<li data-animation="false" data-toggle="tooltip" data-placement="top" title="模型列表" class="tabs_btn_models" id="tabs_btn_models" onclick="toggleTabs(this,1)"></li>
								<li data-animation="false" data-toggle="tooltip" data-placement="top" title="专业结构" class="tabs_btn_type" id="tabs_btn_type" onclick="toggleTabs(this,2)"></li>
								<li data-animation="false" data-toggle="tooltip" data-placement="top" title="楼层" class="tabs_btn_tree" id="tabs_btn_tree" onclick="toggleTabs(this,5)"></li>
							</ul>
						</div>
						<div class="pop_box display_none">
							<div class="arrow arrow1"></div>
							<div class="pop_box_contents">
								<div class="pop_contents_tree display_none">
									<!--树结构-->
									<div class="" style="width: 217px;">
										<ul class="treeview tree_root" id="treeview">
										</ul>
									</div>
								</div>
								<div class="pop_contents_models" style="">
									<span><a href="javascript:void(0);" class="save-viewpoint-but add-model-but" onclick="FnaddModel()">添加模型</a></span>
									<!--模型列表-->
									<div class="" style="width: 217px;">
										<ul id="modeltree">
										</ul>
									</div>
								</div>
								<div class="pop_contents_type display_none">
									<!--类型树结构-->
									<div class="" style="width: 217px;">
										<ul class="treeview type_root" id="typeview">
										</ul>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div data-animation="false" data-toggle="tooltip" data-placement="top" title="帮助" class="tabs_btn_help" id="tabs_btn_help" onclick="toggleTabs(this,4)"></div>
					<div data-animation="false" data-toggle="tooltip" data-placement="top" title="退出" class="tabs_btn_back" id="tabs_btn_back" onclick="toggleTabs(this,0)"></div>
					<!-- 视角坐标值-->
					<input type="hidden" id="hid_posVaule" value="" />
					<!-- 视角缩略图-->
					<input type="hidden" id="hid_posThumbImg" value="" />
					<!-- 加载自定义视角页面-->
					<div id="model_viewpoint" style="display: none;">
						<!--自定义视点 -->
						<div class="rightdiv viewpoint viewpointdiv">
							<div class="right-detection-list">
								<div class="right-detection-list-title">
									<p>自定义视点</p>
									<i class="list-title-close"><img src="${pageContext.request.contextPath}/Themes/default/Content/webimg/toolbar/icon-close.png"></i>
								</div>
								<div class="right-detection-list-main">
									<div class="line-div">
										<button class="save-viewpoint-but" id="viewpoint-but">+保存视点</button>
									</div>
									<div class="viewpoint-list-main " style="overflow-y: auto; min-height: 50px;">
										<div class="line-div"></div>
									</div>
								</div>
							</div>
							<input id="id" name="id" value="0" type="hidden" />
							<div id="viewpoint-modal-main" class="select-modal-div">
								<table class="select-modal-table">
									<tbody>
										<tr>
											<td>
												<p>视点名称:</p>
											</td>
											<td><input type="text" id="posName" name="posName" class="input-text"></td>
										</tr>
										<tr>
											<td>
												<p>描述:</p>
											</td>
											<td><input type="text" id="posDescribe" name="posDescribe" class="input-text"></td>
										</tr>
										<tr>
											<td colspan="2" class="select-modal-but-div">
												<div class="viewpoint-modal-img">
													<img style="width: 100px; height: 80px;" id="posThumbImg" name="posThumbImg" src="">
												</div>
											</td>
										</tr>
									</tbody>
									<tfoot>
										<tr>
											<td colspan="2" class="select-modal-but-div"><button onclick="viewpointsave()" class="ensure-but">保存</button> <input id="close_add_modal" type="button" value="关闭" class="cancel-but"></td>
										</tr>
									<tfoot>
								</table>
							</div>
						</div>
						<!--自定义视点 -->
						<script type="text/javascript">
							//保存自定义视点
							function viewpointsave() {
								console.log("保存自定义视点");
								if ($.trim($("#posName").val()) == "") {
									layer.msg("请填写视角名称！", {
										icon : 0
									});
								} else {
									layer.msg('正在提交数据...', {
										icon : 16,
										shade : [ 0.3, '#000000' ],
										scrollbar : false,
										offset : '45%',
										time : 2000
									});
									var id = $.trim($("#id").val());
									var posName = $.trim($("#posName").val());
									var posValue = $.trim($("#hid_posVaule").val());
									var modelId = $
									{
										mileageID
									}
									;
									var posThumbImgBase64 = $("#hid_posThumbImg").val();
									var posDescribe = $("#posDescribe").val();
									posThumbImgBase64 = posThumbImgBase64.substring(22);
									$.post("${pageContext.request.contextPath}/Position/Edit", {
										id : id,
										posName : posName,
										posValue : posValue,
										modelId : modelId,
										posThumbImg : posThumbImgBase64,
										posDescribe : posDescribe
									}, function(result) {
										if (result == "1") {
											layer.msg('保存成功！', {
												icon : 1,
												time : 2000,
												end : function() {
													var divhtml = "<div class=\"btn bgray setposition\"  style=\"width:150px;text-align:center;" +
																		"line-height:40px; heigth:30px;\">" + "<div data-image=\"" + posThumbImgBase64 + "\" " +
																		" data-value=\"" + posValue + "\">" + posName + "</div>";
													parent.$("#PerspectiveManageList").append(divhtml);
													$(".setposition").on("click", function() {
														$("#btnPerspectiveManage").removeClass("btnPerspectiveManage").addClass("btnhoushijiao");
														$("#btnPerspectiveManage").parent("div.btnjian").addClass("selbtn");
														selbtncolor(this);
														posValue = $(this).children().data("value");
														SetCamera(posValue);
													})
													LoadPostionList();
													console.log(index);
													parent.layer.close(index);
												}
											});
										} else {
											if (result == -1) {
												layer.msg('登录超时,请重新登录！', {
													icon : 2
												});
											} else {
												layer.msg('保存失败！', {
													icon : 2
												});
											}

										}
									});
								}
							}

							//加载视角列表
							function LoadPostionList() {
								$(".right-detection-list .viewpoint-list-main").html("");
								$.get("${pageContext.request.contextPath}/Position/List", {
									modelId : modelId
								}, function(data) {

									if (data == -1) {
										layer.msg('登录超时,请重新登录！', {
											icon : 2
										});
									} else {
										var divhtml = "";
										$.each(data, function(index, item) {
											divhtml += "<div class=\"line-div\">" + "<div data-value=\"" + item.posValue + "\" class=\"line-div-left\">" + "<img style=\"width:81px; height:54px\" src=\"data:image/png;base64," + item.posThumbImg + "\"></div>" + "<div class=\"line-div-right\"><h4 class=\"line-title-h4\">" + item.posName + "</h4>" + "<p>" + item.posDescribe + "</p></div><div class=\"line-div-tool\" data-id=\"" + item.id + "\">" + "<i class=\"icon-edit\"></i>" + "<i class=\"icon-delete\"></i></div></div>"
										});
										//关闭loading
										$.mask_close('.viewpoint-list-main');
										$(".right-detection-list .viewpoint-list-main").height($(window).height() - 250);
										$(".right-detection-list .viewpoint-list-main").append(divhtml);
										$(".line-div").on("click", function() {
											var posVaule = $(this).children().data("value");
											SetCamera(posVaule);
										})

										//修改视点
										$(".line-div-tool .icon-edit").on("click", function() {
											viewpointedit($(this).parent().data("id"));
										})

										//删除视点
										$(".line-div-tool .icon-delete").on("click", function() {
											var id = $(this).parent().data("id");
											layer.confirm('确定要删除吗？', {
												btn : [ '确定', '取消' ]
											//按钮
											}, function() {
												viewpointDelete(id);
											});

										});
									}
								})
							}

							//修改视点
							function viewpointedit(id) {
								$.get("${pageContext.request.contextPath}/Position/GetModel", {
									id : id
								}, function(data) {
									$("#id").val(id);
									$("#posName").val(data.posName);
									$("#posDescribe").val(data.posDescribe);
									$("#posThumbImg").attr("src", "data:image/png;base64," + data.posThumbImg);

								})
								//index = layer.open({
								//    type: 1,
								//    skin: 'layui-layer-lan', //样式类名
								//    anim: 2,
								//    title: ['修改视点', true],
								//    shadeClose: true, //开启遮罩关闭
								//    area: ['400px', '450px'], //宽高
								//    offset: ['100px', '40%'],
								//    content: $('#viewpoint-modal-main')
								//});

								index = layer.open({
									type : 1,
									skin : 'layui-layer-lan', //样式类名
									anim : 2,
									title : [ '修改视点', true ],
									shadeClose : true, //开启遮罩关闭
									area : [ '400px', '450px' ], //宽高
									success : function(layero, index) {
										layer.iframeAuto(index);

									},
									content : $('#viewpoint-modal-main')
								});

							}

							//删除视点
							function viewpointDelete(id) {
								$.get("${pageContext.request.contextPath}/Position/Delete", {
									id : id
								}, function(data) {
									if (data == 1) {
										layer.msg('删除成功！', {
											icon : 1,
											time : 1000,
											end : function() {
												LoadPostionList();
											}
										});
									}
								})
							}
						</script>
					</div>

					<!--加载标签管理页面--->
					<div id="model_tagList" style="display: none;">
						<form id="tagModelForm" class="rightdiv addtagdiv" action="${pageContext.request.contextPath}/model_tag/Edit" method="post" enctype="multipart/form-data">
							<div class="right-detection-list">
								<div class="right-detection-list-title">
									<p>标签登记</p>
								</div>
								<div class="right-detection-list-main">
									<div class="label-form">
										<div>
											<p>标签类型</p>
											<p>
												<input id="hid_tagTypeName" name="hid_tagTypeName" type="hidden" /> <select id="tagType" name="tagType" class="bim-label-select">
													<option value="">请选择标签类型</option>
												</select>
											</p>
										</div>
										<div>
											<p>标签名称</p>
											<p>
												<input id="tagName" name="tagName" class="bim-label-input" type="text">
											</p>
										</div>
										<div>
											<p>标签描述</p>
											<p>
												<input id="tagExplain" name="tagExplain" class="bim-label-input" type="text">
											</p>
										</div>
										<div>
											<p>构建坐标</p>
											<p>
												<input id="componenPosition" readonly="readonly" name="componenPosition" class="bim-label-input" type="text">
											</p>
										</div>
										<div>
											<p class="tagico-list">选择图标</p>
											<div class="icon-input-div">
												<p>
													<img style="width: 20px; height: 20px" data-id="1" src="${pageContext.request.contextPath}/Upload/tag/defaultico.png">default<i class="pitchon_icon"></i>
												</p>
												<input type="hidden" id="hid_icoId" name="icoId" value="1"> <input type="hidden" id="hid_icoUrl" name="icoUrl" value="${pageContext.request.contextPath}/Upload/tag/defaultico.png"> <input type="hidden" id="hid_icoName" name="icoName" value="defaultico"> <i class="icon-input-i" id="icon-input"></i>
												<div class="icon-select" id="icon-select-div">
													<div class="ico-list">ds</div>
													<div class="icon-select-but">
														<input class="ensure-but" id="add-icon-select-modal" value="新增图标" type="button">
													</div>
												</div>
											</div>

										</div>
										<div></div>
										<input id="modelId" name="modelId" type="hidden" /> <input id="componentId" name="componentId" type="hidden" />
										<div class="lead-but-div">
											<input class="ensure-but" value="确定" onclick="tagsave()" type="button" id="btn_submit" /> <input class="cancel-but" type="button" value="取消"> <input id="btnreset" style="display: none" type="reset" value="重置">
										</div>
									</div>
								</div>
							</div>

						</form>
						<form id="tagIcoModelForm" action="${pageContext.request.contextPath}/model_tag/AddIco" method="post" enctype="multipart/form-data">
							<div id="icon-select-modal-main" class="select-modal-div">
								<table class="select-modal-table">
									<tbody>
										<tr>
											<td>图标名称:</td>
											<td><input type="text" id="icoName" name="icoName" class="input-text"></td>
										</tr>
										<tr>
											<td>上传图标:</td>
											<td><input type="file" id="icoUrl" name="icoUrl" class="input-text"><span style="color: red;">注:上传图标大小建议30*30</span></td>
										</tr>
									</tbody>
									<tfoot>
										<tr>
											<td colspan="2" class="select-modal-but-div"><input class="ensure-but" onclick="tagicosave()" value="确定" type="button"> <input id="close_add_modal" class="cancel-but" value="关闭" type="button"> <input id="btnTagIcoreset" style="display: none" type="reset" value="重置"></td>
										</tr>
									<tfoot>
								</table>
							</div>
						</form>

						<hr />

						<script type="text/javascript">
							var AddAnchorIdList = new Array();
							//标签登记
							function tagsave() {
								console.log("标签登记");
								var path = $('#hid_icoUrl').val();
								var name = $('#hid_icoName').val();
								$("#modelId").val("${mileageID}");
								$("#componentId").val(goujianid);
								if ($("#tagType option:selected").val() == "") {
									layer.msg("请填写标签类型！", {
										icon : 0
									});
								} else if ($.trim($("#tagName").val()) == "") {
									layer.msg("请填写标签名称！", {
										icon : 0
									});
								} else {
									$("#hid_tagTypeName").val($("#tagType option:selected").text());
									$("#tagModelForm").ajaxSubmit(function(d) {
										layer.closeAll();
										if (d > 0) {
											AddAnchorIdList.push(d);
											$("#btnreset").click();
											//RemoveAnchor('defaultico');//移除默认标签
											console.log("addtag:" + name + "_" + d);
											//AddAnchor(clickpos, path, 1.0, 1.0, name + "_" + d);//添加标签
											//IsAddTag = false;
											layer.msg('保存成功！', {
												icon : 1,
												time : 1000,
												end : function() {
													var index = parent.layer.getFrameIndex(window.name);
													console.log(index);
													parent.layer.close(index);
												}
											});
										} else {
											layer.msg('保存失败！', {
												icon : 2
											});
										}
									});
								}
							}
							//新增标签图标
							function tagicosave() {
								if ($.trim($("#icoName").val()) == "") {
									layer.msg("请填写图标名称！", {
										icon : 0
									});
								} else if ($.trim($("#icoUrl").val()) == "") {
									layer.msg("请上传图标！", {
										icon : 0
									});
								} else {
									$("#tagIcoModelForm").ajaxSubmit(function(d) {
										layer.closeAll();
										if (d == "1") {
											$("#btnTagIcoreset").click();
											layer.msg('保存成功！', {
												icon : 1,
												time : 500,
												end : function() {
													LoadIcoList();
													var index = parent.layer.getFrameIndex(window.name);
													console.log(index);
													parent.layer.close(index);
												}
											});
										} else {
											alert(d);
											layer.msg('保存失败！', {
												icon : 2
											});
										}
									});
								}
							}

							$(".icon-input-i").on("click", function() {
								LoadIcoList();
							})
							//LoadIcoList();
							//加载标签图片列表
							function LoadIcoList() {

								$(".icon-select .ico-list").html("");
								$.get("${pageContext.request.contextPath}/Ajax/GetTagIcoList", function(data) {
									console.log("invoked GetTagIcoList");
									var count = data.length;
									var divhtml = "";
									for (var i = 0; i < count; i++) {
										divhtml += "<p><img style=\"width:30px; height:30px\" data-id=" + data[i].id + " src=" + data[i].icoUrl + ">" + data[i].icoName + "<i class=\"pitchon_icon\"></i></p>";
									}
									$(".icon-select .ico-list").append(divhtml);
									$('#icon-select-div p').click(function() {
										$('#icon-select-div p').children('i').hide();
										$(this).children('i').show();
										$('#icon-select-div').hide();
										var html_seletc = $(this).html();
										var html_text = $(this).text();
										var html_id = $(this).children().data("id");
										var html_src = $(this).children().attr("src");
										$('.icon-input-div>p').html(html_seletc);
										$('.icon-input-div #hid_icoId').val(html_id);
										$('.icon-input-div #hid_icoUrl').val(html_src);
										$('.icon-input-div #hid_icoName').val(html_text);
									});
									//var defaultico = $('#icon-select-div p').eq(0).html();
									//$('.icon-input-div>p').html(defaultico);
									//$('.icon-input-div #hid_icoId').val($('#icon-select-div p').eq(0).children().data("id"));
									//$('.icon-input-div #hid_icoUrl').val($('#icon-select-div p').eq(0).children().attr("src"));
									//$('.icon-input-div #hid_icoName').val($('#icon-select-div p').eq(0).text());

								})
							}
						</script>
					</div>

					<!--加载未处理标签--->
					<div id="model_tagUntreatedList" style="display: none;">
						<!-- 右侧检测结果 -->
						<form id="tagIModelListForm" class="rightdiv histroytagdiv" action="${pageContext.request.contextPath}/model_tag/AddIco" method="post" enctype="multipart/form-data">
							<div class="right-detection-list">
								<div class="right-detection-list-title">
									<p>历史标签</p>
									<i class="list-title-close"><img src="${pageContext.request.contextPath}/Themes/default/Content/webimg/toolbar/icon-close.png"></i>
								</div>
								<div id="tagdivloading" class="right-detection-list-main" style="width: 260px; overflow-y: auto; min-height: 50px;"></div>
							</div>
						</form>
						<script>
							var indexLoading = 0;
							function LoadTagList() {
								console.log("加载标签列表");
								RemoveAnchor('defaultico'); //移除默认标签
								if (AddAnchorIdList == "" || AddAnchorIdList == undefined) {
									AddAnchorIdList = new Array("0");
								}
								$("#tagIModelListForm .right-detection-list-main").html("");
								var modelId = "${mileageID}";
								$.get("${pageContext.request.contextPath}/Ajax/GetTagList", {
									modelId : modelId
								}, function(data) {
									console.log("invoked GetTagList");
									var count = data.length;
									var divhtml = "";
									if (count == 0) {
										divhtml = "未找到记录!";
									}
									var classname = "check_slider1 check_slider_hecked1";
									for (var i = 0; i < count; i++) {
										//var index = AddAnchorIdList.indexOf(''+data[i].id+'');
										//if (index > -1) {
										//    classname = "check_slider1 check_slider_hecked1";
										//}
										divhtml += "<div class=\"line-div\"  data-componenposition=" + data[i].componenPosition + ">" + "<p><span data-componenposition=" + data[i].componenPosition + " data-iconame=" + data[i].icoName + "_" + data[i].id + " data-icourl=" + data[i].icoUrl + " id=\"tagDisplay\" class=\"t_checkbox1\"><i class=\"" + classname + "\"></i></span></p>" + " <p style=\"margin-left:50px!important\">标签类型：" + data[i].tagType + "</p>" + " <p onclick=\"fnmsk()\" style=\"margin-left:50px!important\">标签名称：" + data[i].tagName + "</p>" + "</div>";
									}
									//关闭loading
									$.mask_close('#tagdivloading');
									$("#tagdivloading").height($(window).height() - 200);
									$("#tagIModelListForm .right-detection-list-main").append(divhtml);
									//显示隐藏
									$(" #tagDisplay").click(function() {
										var componenposition = $(this).data("componenposition");
										var icoUrl = $(this).data("icourl");
										var icoName = $(this).data("iconame");
										//切换选中状态
										if ($(this).find("i.check_slider1").hasClass("check_slider_hecked1")) {
											$(this).find("i.check_slider1").removeClass("check_slider_hecked1");
											//RemoveAnchor('defaultico');//移除默认标签
											RemoveAnchor(icoName); //移除标签
										} else {
											$(this).find("i.check_slider1").addClass("check_slider_hecked1");
											console.log(componenposition);
											AddAnchor(componenposition, icoUrl, 1.0, 1.0, icoName);

										}
									});

									$(".line-div").bind("dblclick", function() {
										$(".line-div").removeClass("line_div_bg");
										$(this).addClass("line_div_bg");
										ZoomTo($(this).data("componenposition"));
									})
									$('#icon-select-div p').click(function() {
										$('#icon-select-div p').children('i').hide();
										$(this).children('i').show();
										$('#icon-select-div').hide();
										var html_seletc = $(this).html();
										var html_text = $(this).text();
										$('.icon-input-div>p').html(html_seletc);
										$('.icon-input-div>input').val(html_text);
									});
									//console.log(indexLoading);
									//parent.layer.close(indexLoading);

								})
							}

							//加载所有标签定位
							function LoadTagSiteList() {
								console.log("加载所有标签定位");
								var modelId = "${mileageID}";
								$.get("${pageContext.request.contextPath}/Ajax/GetTagSiteList", {
									modelId : modelId
								}, function(data) {
									console.log("invoked GetTagSiteList");
									$.each(data, function(i, item) {
										AddAnchor(item.tagSite, item.icoUrl, 1.0, 1.0, item.icoName + "_" + item.tagId); //添加标签
									})
								})
							}
						</script>
					</div>
					<input type="hidden" id="hid_ThumbImg" value="1" />
					<!--用户引导开始-->
					<div id="walkthrough-content" style="display: none;">
						<div id="walkthrough-1">
							<h3>欢迎使用</h3>
							<p>
								<span>GL WebGL BIM Engine</span>是一款轻量级专业三维可视化引擎，是当前BIM应用开发的最佳商业引擎组件选择！<br />
							</p>
							<p>点击下一步了解更多...</p>
						</div>
						<div id="walkthrough-2">这里是模型列表，点击展开可以看到可加载的模型，打开开关加载该模型，关闭则移除该模型。</div>
						<div id="walkthrough-3">点击这里可以查看该模型的结构树，点击某一节点可漫游到该元素</div>
						<div id="walkthrough-4">点击这里查看选中的模型元素的属性信息</div>
						<div id="walkthrough-5">这里是一些功能按钮，包括视图选择、模型测量、爆炸、透明、剖切等功能...</div>
						<div id="walkthrough-6">这是使用帮助，可以帮助您更轻熟的使用本系统</div>
						<div id="walkthrough-7">退出，点击退出会回退到模型列表页</div>
					</div>
					<!--用户引导结束-->
				</div>
				<!-- i内容显示  -->
				<div class="rightdiv SandBoxLisInfo" id="SandBoxLisInfo">
					<div class="SandBoxInfo_text display_none" id="sandBoxInfo_text_div" style="border: none; display: block;">
						<!--基本信息-->
						<div class="box box-Sand box-default">
							<div class="box-header with-border box-header-Sand">
								<h4 class="box-title" style="font-family: 'Microsoft Yahei', Verdana, Simsun, 'Segoe UI Web Light', 'Segoe UI Light', 'Segoe UI Web Regular', 'Segoe UI', 'Segoe UI Symbol', 'Helvetica Neue', Arial;">基本信息</h4>
							</div>
							<div class="box-body Sand-info SandBoxInfo_text_scrollbar collapse_default1 mCustomScrollbar _mCS_7" id="attrprop">
								<div id="mCSB_7" class="mCustomScrollBox mCS-dark mCSB_vertical mCSB_inside" tabindex="0">
									<div id="mCSB_7_container" class="mCSB_container" style="position: relative; top: 0px; left: 0px;" dir="ltr">
										<div class="btn_div">
											<ul id="myTab" class="nav nav-tabs myTab_ultype">
												<li data-type="properties" class="active"><a href="#properties" data-toggle="tab">属性</a></li>
												<li data-type="materials"><a href="#materials" data-toggle="tab">材质</a></li>
												<li data-type="object"><a href="#object" data-toggle="tab">特性</a></li>
												<li data-type="type"><a href="#type" data-toggle="tab">类型</a></li>
											</ul>
										</div>
										<div id="myTabContent" class="tab-content" style="position: relative; overflow: auto; height: 350px; max-width: 100%; outline: 0; direction: ltr;">
											<div class="tab-pane fade" id="type"></div>
											<div class="tab-pane fade" id="properties"></div>
											<div class="tab-pane fade" id="object"></div>
											<div class="tab-pane fade" id="materials"></div>

										</div>
									</div>
								</div>
							</div>
						</div>
						<!--/基本信息-->
					</div>
					<div id="imitate_div" class="display_none">
						<div class="time_axis_ch"></div>
						<div class="time_axis_main">
							<div class="time_axis_line"></div>
							<ul id="time_axisDiv">
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/jquery-3.0.0.min.js"></script>
	<script src="${pageContext.request.contextPath}/Content/plugins/JqueryLoading/load.js"></script>
	<script src="${pageContext.request.contextPath}/Content/bootstrap/js/bootstrap3.3.7.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/toolsbar.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/Common.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/jquery-migrate-1.2.1.min.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/simpletooltip.min.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/script_GL_WebGL_BIM_Engine.js"></script>
	<script src="${pageContext.request.contextPath}/Content/plugins/layer/layer.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/colpick.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/3dEngine.js"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/pagewalkthrough/jquery.pagewalkthrough.min.js" charset="gbk"></script>
	<script src="${pageContext.request.contextPath}/Themes/default/Content/Scripts/simple.js"></script>
	<script src="${pageContext.request.contextPath}/Content/plugins/jquery/jquery.form.min.js"></script>
	<script type="text/javascript">
		var Queue = function() {
			this.dataStore = [];
		}
		Queue.prototype = {
			//入队，就是在数组的末尾添加一个元素
			enqueue : function(element) {
				this.dataStore.push(element);
			},
			//出队，就是删除数组的第一个元素
			dequeue : function() {
				return this.dataStore.shift();
			},
			//取出数组的第一个元素
			front : function() {
				return this.dataStore[0];
			},
			//取出数组的最后一个元素
			back : function() {
				return this.dataStore[this.dataStore.length - 1];
			},
			toString : function() {
				var retStr = "";
				for (var i = 0; i < this.dataStore.length; ++i) {
					retStr += this.dataStore[i] + "&nbsp;"
				}
				return retStr;
			},
			//判断数组是否为空
			empty : function() {
				if (this.dataStore.length == 0) {
					return true;
				} else {
					return false;
				}
			},
			//返回数组中元素的个数
			count : function() {
				return this.dataStore.length;
			}
		};
		var q = new Queue();
		var Mids = []; //
		var selObjectColor = "#ff0000"; //选中对象默认颜色
		var ctrlKey = false; //ctrl键
		var goujianid = 0; //构件ID
		var goujianListId = new Array(); //构件ID数组
		var isRoam = true; //是否漫游
		var IsAddTag = false; //是否添加标签
		//var goujianIndex = 0;//构件数组索引
		var goujianidLast = 0; //记录上次构件ID
		var clickpos = ''; //选中的坐标
		var defview = ''; //旋转中心点
		var clickMode = ''; //鼠标点击模式
		//监听ctrl键按下
		$(window).keydown(function(e) {
			ctrlKey = e.ctrlKey;
		});
		//监听ctrl键松开
		$(window).keyup(function(e) {
			ctrlKey = e.ctrlKey;
		});

		//保存项目快照图
		function SaveLineMileageImg() {
			console.log("保存项目快照图");
			if ($("#hid_ThumbImg").val() == "0" || $("#hid_ThumbImg").val() == "") {
				var base64image = GetImage();
				var hid_modelid = "${mileageID}";
				base64image = base64image.substring(22);
				//console.log(base64image);
				$.post("${pageContext.request.contextPath}/Ajax/UpdateLineMileageImg", {
					MileageID : hid_modelid,
					base64image : base64image
				}, function(data) {
					console.log("invoked UpdateLineMileageImg");
					console.log(data);
				})
			}
		}
		$(function() {
			$("#webcanvas").height($(document).height());
			//index = layer.msg('正在加载模型...', { icon: 16, shade: [0.3, '#000000'], scrollbar: false, offset: '45%', time: 222000 });
			EngineInit("webcanvas");
			SetBackGroundColor(255, 255, 255);
			inittoolsbar("webglContainer");
			SetZoomSpeed(0.05);
			SetRotateSpeed(2.5);
			SetPanSpeed(2.5);
			SetSelectState(true);
			SetClickMode(0);
			//setsimplestyle();//设置模型加载风格
			$("[data-toggle='tooltip']").tooltip(); //设置title样式
			var id = "${mileageID}";
			if (id == null || id == "" || id == "undifine") {
				alert("参数传递错误");
			} else {
				$.get("${pageContext.request.contextPath}/Ajax/GetModelTreeData?MileageID=" + id, function(data) {
					console.log("invoked GetModelTreeData");
					var obj = document.getElementById("modeltree");
					jQuery.each(data, function(i, item) {
						var MileageID = item.MileageID;
						q.enqueue(MileageID);
						Mids.push(MileageID);
					});
					initAddModel();
				})
			}
		});
		//监听点击的坐标    
		function OnClickPosition(position) {
			clickpos = position;
			if (clickMode == 1) {
				ZoomTo(clickpos);
				SetPivot(clickpos);
			} else {
				if (IsAddTag) {
					FnShowAddTag(); //显示增加标签
					RemoveAnchor('defaultico'); //移除默认标签
					AddAnchor(clickpos, '/Upload/tag/defaultico.png', 1.0, 1.0, 'defaultico');
				}
			}
		}
		//构件着色
		function FnSetActorColor(goujianid) {
			var r = parseInt(selObjectColor.substr(1, 2), 16);
			var g = parseInt(selObjectColor.substr(3, 2), 16);
			var b = parseInt(selObjectColor.substr(5, 2), 16);
			SetActorColor(goujianid, r, g, b);
		}
		//鼠标选中事件
		function OnSelectionChanged(guids) {
			console.log("选择变更事件");
			if (clickMode == 2) {
				if (guids != "undefined") {
					//if (!IsAddTag) {
					var guids = goujianid = guids;
					if (ctrlKey) { //按下ctrl键则给构件着色
						SetSelectState(false);
						if (goujianListId.indexOf(goujianid) > -1) {
							ResetActor(goujianid); //恢复构建状态
							goujianListId.splice($.inArray(goujianid, goujianListId), 1);
						} else {
							goujianListId.push(goujianid);
							FnSetActorColor(goujianid); //构件着色
						}
					} else {
						mouseClickEvent(goujianid); //鼠标单击处理
					}
					if (clickMode == 2) {
						if (!$(".SandBoxLisInfo").is(':hidden')) {
							mdldetailshow(goujianid, type); //显示属性
						}
					}
				}
			}
		}
		//鼠标单击处理
		function mouseClickEvent(goujianid) {
			SetSelectState(true);
			//批量恢复构件数组颜色
			if (goujianListId.length > 1) {
				//$.each(goujianListId, function (index, item) {
				//    ResetActor(goujianListId[index]);
				//})
				goujianListId.splice(0, goujianListId.length); //移除多选的元素
			}

			//如果已上色则去除颜色
			if (goujianListId.length > 0) {
				if (goujianListId[0] == goujianid) {
					GoBackState(goujianid);
					goujianListId.shift();
				} else {
					FnSetActorColor(goujianid);
					goujianListId.push(goujianid);
					GoBackState(goujianListId[0]);
					goujianListId.shift();
				}
			} else {
				FnSetActorColor(goujianid); //构件着色
				goujianListId.push(goujianid);
			}
		}
		//鼠标点击空白处事件
		function OnClickBlank() {
			$(".toolsbar>div>div.grouptools").removeClass("btn_s").addClass("btn_c"); //关闭所有二级菜单
			// closeRightWindow();//关闭所有右侧层
			IsAddTag = false; //关闭标签登记标识
			$("body").css("cursor", "default"); //还原鼠标样式
		}
		function initAddModel() {
			console.log("添加模型");
			layer.close(index); //关闭loading
			if (q.count() > 0) {
				var id = q.front();
				$.get("${pageContext.request.contextPath}/Ajax/GetModelData?MileageID=" + id, function(data) {
					console.log("invoked GetModelData");
					var obj = document.getElementById("modeltree");
					var MileageName = data.MileageName;
					var SOidModelFile = $.trim(data.SOidModelFile);
					var MileageID = $.trim(data.MileageID);
					defview = data.DefViewPoint;
					var options = '<li>' + '<label class="model_title" id="' + SOidModelFile + '" title="' + MileageName + '">' + MileageName + '</label>' + '<span class="checkbox float_right">' + '<input id="checkbox_' + MileageID + '" class="chk_3" checked type="checkbox" att_file="' + SOidModelFile + '" att_mid="' + MileageID + '" onclick="checkmodel(this);">' + '<label for="checkbox_' + MileageID + '"></label>' + '</span>' + '</li>';
					$(obj).append(options);

					//加载模型
					var filepath = '${pageContext.request.contextPath}/Tools/output/' + SOidModelFile + "/" + SOidModelFile + 'List.json';
					AddModel(filepath, MileageID);
				})
			}
		}

		//加载完成事件
		function OnLoadModelEnd(guid) {
			console.log("加载完成事件");
			if (defview != null) {
				SetCamera(defview);
			}
			var MileageID = "${mileageID}";
			q.dequeue();
			initAddModel();
			SaveLineMileageImg(); //保存项目快照图
			//SetModelAlpha(guid, 0.7);//模型默认透明度
			//ZoomFitAll();
			$("#typeview").html("");
			$("#treeview").html("");
			$.get("${pageContext.request.contextPath}/Ajax/GetModelData?MileageID=" + MileageID, function(data) {
				console.log("invoked GetModelData");
				var obj = document.getElementById("modeltree");
				var SpecialtyName = data.SpecialtyName;
				var MileageName = data.MileageName;
				var SOidModelFile = $.trim(data.SOidModelFile);
				var MileageID = $.trim(data.MileageID);
				//加载装配
				//            var options = '<li><i class="i_tree_expan level0" onclick="bindzstoggle(this,0)" attr_loading="0" id="0" num="0" filename="' + SOidModelFile + '" mid="' + MileageID + '"></i>\
				//<i class="i_tree_file"></i>\
				//<span class="tree_leave" title="' + MileageName + '">' + MileageName + '</span>\
				//<ul class="treeview tree_ul_display_none" id="ul_' + MileageID + '"></ul></li>';

				var options = '<li><i class="i_tree_expan level0" onclick="bindProTreeRootNode(this,' + MileageID + ')" type_attr_loading="0" id="0" type_num="0"></i>' + '<i class="i_tree_file"></i>' + '<span class="tree_leave" >' + SpecialtyName + '</span>' + '<ul class="treeview tree_ul_display_none" id="ProTreeRootNode_type_ul_' + MileageID + '"></ul></li>';
				$("#treeview").html(options);
				//加载类型
				var optionstype = '<li><i class="i_tree_expan level0 " onclick="bindProRootNode(this,' + MileageID + ')" type_attr_loading="0" id="0" type_num="0"></i>' + '<i class="i_tree_file"></i>' + '<span class="tree_leave" >' + SpecialtyName + '</span>' + '<ul class="treeview tree_ul_display_none" id="ProRootNode_type_ul_' + MileageID + '"></ul></li>';
				$("#typeview").html(optionstype);
				//$.mask_element('#typeview ul', 3000);//显示loading
				//bindzstoggle(0);
				showTips();
				//bindType(0);

			})
			//$("i.i_tree_expan").on("click", function () {
			//    i_checkbox_toggle(this);
			//});
			//getproone(SOidModelFile, MileageID)
			onloadFun(); //滚动条

			//layer.close(index);//关闭loading
		}
		function checkmodel(obj) {
			var file = $.trim($(obj).attr("att_file"));
			var mid = $.trim($(obj).attr("att_mid"));
			if ($(obj).prop("checked")) {
				SetModelVisible(mid, true)
			} else {
				SetModelVisible(mid, false)
				canselbtncolor();
			}
		}

		//装配项目根节点
		function bindProTreeRootNode(obj, MileageID) {
			if ($(obj).parent("li").children("ul.treeview").hasClass("tree_ul_display_none")) {
				$(obj).parent("li").children("ul.treeview").removeClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").addClass("i_tree_retract");
				$(obj).parent("li").children("i.i_tree_expan").addClass("treeloading");
				$.get("${pageContext.request.contextPath}/Ajax/GetPropertyTypeItemList?MileageID=" + MileageID, function(data) {
					console.log("invoked GetPropertyTypeItemList");
					var options = "";
					$.each(data, function(index, item) {
						options += '<li><i class="i_tree_expan level0" onclick="bindzstoggle(this,0)" attr_loading="0"' + 'id="0" num="0" filename="' + item.SOidModelFile + '" mid="' + item.MileageID + '"></i>' + '<i class="i_tree_file"></i>' + '<span class="tree_leave" title="' + item.MileageName + '">' + item.MileageName + '</span>' + '<ul class="treeview tree_ul_display_none" id="ul_' + item.MileageID + '"></ul></li>';
					})
					$("#ProTreeRootNode_type_ul_" + MileageID).html(options);
					$(obj).parent("li").children("i.i_tree_expan").removeClass("treeloading");
				});
			} else {
				$(obj).parent("li").children("ul.treeview").addClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").removeClass("i_tree_retract");
			}
			showTips();
		}
		function bindzstoggle(obj, level) {
			// $("ul.treeview>li").has("ul.treeview").map(function () {
			//$(this).children("i.i_tree_expan").removeClass("visibility_hidden");
			//$(this).children("span.tree_leave").on("click",expan_tree_ul(this));
			// $("#treeview i.level" + level).click(function () {
			//展开子元素中的ul
			if ($(obj).parent("li").children("ul.treeview").hasClass("tree_ul_display_none")) {
				$(obj).parent("li").children("ul.treeview").removeClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").addClass("i_tree_retract");
				var id = $(obj).attr("id");
				var filename = $(obj).attr("filename");
				var mid = $(obj).attr("mid");
				var num = $(obj).attr("num");
				var isloading = $(obj).attr("attr_loading");
				if (isloading * 1 == 0) {
					if (num == 0) {
						getproone(filename, mid)
						$(obj).attr("attr_loading", 1);
					} else {
						getprotwo(id, filename, mid);
						$(obj).attr("attr_loading", 1);
					}
				}
			} else {
				$(obj).parent("li").children("ul.treeview").addClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").removeClass("i_tree_retract");
			}
			showTips();
			//});
			//if ($(this).children("ul.treeview").hasClass("tree_ul_display_none")) {
			// $(this).children("i.i_tree_expan").removeClass("i_tree_retract");
			//} else {
			// $(this).children("i.i_tree_expan").addClass("i_tree_retract");
			// }
			// });

		}

		function getproone(SOidModelFile, MileageID) {
			$.get("${pageContext.request.contextPath}/Ajax/GetPropertyTreeData?MileageID=" + MileageID + "&filename=" + SOidModelFile, function(data) {
				console.log("invoked GetPropertyTreeData");
				var newdata = data; // eval("(" + data + ")");
				var obj = document.getElementById("ul_" + MileageID);
				jQuery(obj).html("");
				var optionsstr = "";
				jQuery.each(newdata, function(i, item) {
					var gid = newdata[i].glid;
					var pid = newdata[i].pGlid;
					var name = newdata[i].name;
					var groupname = newdata[i].groupname;
					var ExternalId = newdata[i].externalId;
					pid = gid;
					optionsstr = optionsstr + '<li><i class="i_tree_expan level1" onclick="bindzstoggle(this,1)" attr_loading="0" num="1" id="' + pid + '" filename="' + SOidModelFile + '" mid="' + MileageID + '"></i><i class="i_tree_checkbox i_one i_tree_checked" onclick="i_checkbox_toggle(this, \'GetChildId\')" id="' + pid + '" att_filename="' + SOidModelFile + '" att_type="1" att_val="' + MileageID + '_' + ExternalId + '"></i><span class="tree_leave" id="' + ExternalId + '" title="' + name + '">' + name + '</span><ul class="treeview tree_ul_display_none" id="ul_' + pid + '"></ul></li>';
				});
				jQuery(obj).append(optionsstr);
				$("#treeview i.i_one").click(function() {
					//i_checkbox_toggle(this, "GetChildId");
				});
				//$("i.i_tree_checkbox").on("click", function () {

				//});
				//bindzstoggle(1);
				showTips()
				//$(".cbktree").click(function () {
				//    var extid = $(this).val();
				//    var fid = $(this).attr("fid");
				//    var filename = $(this).attr("filename");
				//    if ($(this).prop("checked")) {
				//        $.get("/Ajax/GetChildId?extid=" + extid + "&filename=" + filename, function (dataextid) {
				//            //var newdata = eval("(" + dataextid + ")");
				//            SetActorVisible(dataextid, true, 0);
				//            $("input[fid=\"" + fid + "\"]").prop("checked", true);
				//        });
				//    } else {
				//        $.get("/Ajax/GetChildId?extid=" + extid + "&filename=" + filename, function (dataextid) {
				//            var newextid = dataextid;
				//            //var newdata = eval("(" + dataextid + ")");
				//            SetActorVisible(dataextid, false, 0);
				//            $("input[fid=\"" + fid + "\"]").prop("checked", false);
				//        });
				//    }
				//});

			})
		}

		function getprotwo(id, filename, mid) {
			layer.load();
			$.ajax({
				async : true,
				type : "POST",
				url : "${pageContext.request.contextPath}/Ajax/GetPropertyTwo?MileageID=" + mid + "&pid=" + id + "&filename=" + filename,
				dataType : 'json',
				success : function(data) {
					console.log("invoked GetPropertyTwo");
					var newdata = data;
					var obj = document.getElementById("ul_" + id);
					jQuery(obj).html("");
					var option = "";
					jQuery.each(newdata, function(i, item) {
						var gid = newdata[i].glid;
						var pid = newdata[i].pGlid;
						var name = newdata[i].name;
						var groupname = newdata[i].groupname;
						var ExternalId = newdata[i].externalId;
						var level = newdata[i].level;
						pid = gid;
						option = option + '<li><i class="i_tree_expan level1" onclick="bindzstoggle(this,1)" attr_loading="0" num="' + level + '" id="' + pid + '" filename="' + filename + '" mid="' + mid + '"></i><i class="i_tree_checkbox i_one i_tree_checked" onclick="i_checkbox_toggle(this, \'GetChildId\')" id="' + pid + '" att_filename="' + filename + '" att_type="1" att_val="' + mid + '_' + ExternalId + '"></i><span class="tree_leave" id="' + ExternalId + '" title="' + name + '">' + name + '</span><ul class="treeview tree_ul_display_none" id="ul_' + pid + '"></ul></li>';
					});
					layer.closeAll();
					jQuery(obj).append(option);
					// $("#treeview i.i_one").click(function () {
					// });
					//bindzstoggle(1);
					$("span.tree_leave").on("click", function() {
						var gid = $(this).attr("val");
						var newid = $(this).parent("li").children("i.i_tree_checkbox").attr("att_val");
						var filename = $(this).parent("li").children("i.i_tree_checkbox").attr("att_filename");
						//detailshow(gid, filename);
						//alert(newid);
						if (isRoam) {
							ZoomTo(newid);
						}
						mouseClickEvent(newid); //鼠标单击处理

						//SetActorAlpha(newid, 0.5, 1);
					});
					//$(".prodetail").click(function () {
					//    var gid = $(this).attr("val");
					//    var extid = $(this).attr("ExtId");
					//    var newid = mid + "_" + extid;
					//    detailshow(gid, filename);
					//    ZoomTo(newid);
					//    SetActorAlpha(newid, 0.1, 1);
					//});
					//$(".cbktree").click(function () {
					//    var extid = $(this).val();
					//    if ($(this).prop("checked")) {
					//        SetActorVisible(extid, true, 0);
					//        $("cbk_" + extid).prop("checked", true);
					//    } else {
					//        SetActorVisible(extid, false, 0);
					//        $("cbk_" + extid).prop("checked", false);
					//    }
					//});
					onloadFun(); //滚动条
				}
			});
		}

		//类型项目根节点
		function bindProRootNode(obj, MileageID) {
			if ($(obj).parent("li").children("ul.treeview").hasClass("tree_ul_display_none")) {
				$(obj).parent("li").children("ul.treeview").removeClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").addClass("i_tree_retract");
				$(obj).parent("li").children("i.i_tree_expan").removeClass("treeloading");
				$.get("${pageContext.request.contextPath}/Ajax/GetPropertyTypeItemList?MileageID=" + MileageID, function(data) {
					console.log("invoked GetPropertyTypeItemList");
					// var obj = document.getElementById("type_ul_" + MileageID);
					var optionstype = "";
					$.each(data, function(index, item) {
						optionstype += '<li><i class="i_tree_expan level1" onclick="bindType(this,0)" type_attr_loading="0"\
    id="0" type_num="0" type_filename="' + item.SOidModelFile + '" mid="' + item.MileageID + '"></i>\
    <i class="i_tree_file"></i>\
    <span class="tree_leave" title="' + item.MileageName + '">' + item.MileageName + '</span>\
    <ul class="treeview tree_ul_display_none" id="type_ul_' + item.MileageID + '"></ul></li>';
					})
					$("#ProRootNode_type_ul_" + MileageID).html(optionstype);
					$(obj).parent("li").children("i.i_tree_expan").removeClass("treeloading");
				});

			} else {
				$(obj).parent("li").children("ul.treeview").addClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").removeClass("i_tree_retract");
			}
		}

		//类型
		function bindType(obj, level) {
			// $("#typeview i.level" + level).click(function () {
			//展开子元素中的ul
			if ($(obj).parent("li").children("ul.treeview").hasClass("tree_ul_display_none")) {
				$(obj).parent("li").children("ul.treeview").removeClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").addClass("i_tree_retract");
				var id = $(obj).attr("id");
				var filename = $(obj).attr("type_filename");
				var mid = $(obj).attr("mid");
				var num = $(obj).attr("type_num");
				var isloading = $(obj).attr("type_attr_loading");
				if (isloading * 1 == 0) {
					if (num == 0) {
						getTypeParentList(filename, mid)
						$(obj).attr("type_attr_loading", 1);
					} else {
						getTypeParentListTwo(id, filename, mid);
						$(obj).attr("type_attr_loading", 1);
					}
				}
				// getTypeParentList(filename, mid)
			} else {
				$(obj).parent("li").children("ul.treeview").addClass("tree_ul_display_none");
				$(obj).parent("li").children("i.i_tree_expan").removeClass("i_tree_retract");
			}
			//})
		}

		function getTypeParentList(SOidModelFile, MileageID) {
			$.get("${pageContext.request.contextPath}/Ajax/GetPropertyTypeData?MileageID=" + MileageID, function(data) {
				console.log("invoked GetPropertyTypeData");
				var newdata = data; // eval("(" + data + ")");
				//var obj = document.getElementById("type_ul_" + MileageID);
				var obj = document.getElementById("type_ul_" + MileageID);
				jQuery(obj).html("");
				var optionsstr = "";
				jQuery.each(newdata, function(i, item) {
					var gid = newdata[i].Glid;
					var gid = newdata[i].glid;
					var pid = newdata[i].pGlid;
					var name = newdata[i].name;
					var groupname = newdata[i].groupname;
					var ExternalId = newdata[i].externalId;
					pid = gid;
					optionsstr = optionsstr + '<li><i class="i_tree_expan level1" onclick="bindType(this,1)" type_attr_loading="0" type_num="1" id="' + pid + '" type_filename="' + SOidModelFile + '" mid="' + MileageID + '"></i><i class="i_tree_checkbox i_one i_tree_checked" onclick="i_checkbox_toggle(this, \'GetTypeChildId\')"  id="' + pid + '" att_filename="' + SOidModelFile + '" att_type="1" att_val="' + MileageID + '_' + ExternalId + '"></i><span class="tree_leave" id="' + ExternalId + '" title="' + name + '">' + name + '</span><ul class="treeview tree_ul_display_none" id="type_ul_' + pid + '"></ul></li>';
				});
				//$("#typeview").append(optionsstr);
				jQuery(obj).append(optionsstr);

				//$("i.i_tree_checkbox").on("click", function () {

				//});
				//bindType(1);
				showTips()
			})
		}

		function getTypeParentListTwo(id, filename, mid) {
			layer.load();
			$.ajax({
				async : true,
				type : "POST",
				url : "${pageContext.request.contextPath}/Ajax/GetPropertyTypeDataTwo?MileageID=" + mid + "&pid=" + id + "&filename=" + filename,
				dataType : 'json',
				success : function(data) {
					console.log("invoked GetPropertyTypeDataTwo");
					var newdata = data;
					var obj = document.getElementById("type_ul_" + id);
					jQuery(obj).html("");
					var option = "";
					jQuery.each(newdata, function(i, item) {
						var gid = newdata[i].glid;
						var pid = newdata[i].pGlid;
						var name = newdata[i].name;
						var groupname = newdata[i].groupname;
						var ExternalId = newdata[i].externalId;
						var level = newdata[i].level;
						pid = gid;
						option = option + '<li><i class="i_tree_expan level1" onclick="bindType(this,1)" attr_loading="0" type_num="' + level + '" id="' + pid + '" filename="' + filename + '" mid="' + mid + '"></i><i class="i_tree_checkbox i_one i_tree_checked" onclick="i_checkbox_toggle(this, \'GetTypeChildId\')"  id="' + pid + '" att_filename="' + filename + '" att_type="1" att_val="' + mid + '_' + ExternalId + '"></i><span class="tree_leave" id="' + ExternalId + '" title="' + name + '">' + name + '</span><ul class="treeview tree_ul_display_none" id="type_ul_' + pid + '"></ul></li>';
					});
					layer.closeAll();
					jQuery(obj).append(option);

					//$("#typeview i.i_one").click(function () {
					//   // i_checkbox_toggle(this, "GetTypeChildId");
					//});
					//bindType(1);
					$("span.tree_leave").on("click", function() {
						var gid = $(this).attr("val");
						var newid = $(this).parent("li").children("i.i_tree_checkbox").attr("att_val");
						var filename = $(this).parent("li").children("i.i_tree_checkbox").attr("att_filename");
						//detailshow(gid, filename);
						//alert(newid);
						if (isRoam) {
							ZoomTo(newid);
						}
						mouseClickEvent(newid); //鼠标单击处理
					});
					onloadFun(); //滚动条
				}
			});
		}

		function mdldetailshow(id, propertyTypeName) {
			var obj = $("#myTabContent #" + propertyTypeName);
			jQuery(obj).html("");
			$.mask_element('#myTabContent', 3000); //显示loading
			//obj.addClass(" active in");//显示选项卡
			$.get("${pageContext.request.contextPath}/Ajax/GetmdlPropertyDetails?mid=" + id + "&propertyTypeName=" + propertyTypeName, function(data) {
				console.log("invoked GetmdlPropertyDetails");
				if (data != "" && data != null) {
					var newdata = data; // eval("(" + data + ")");
					var option = "";
					var groupstr = "";
					if (newdata.length > 0) {
						jQuery.each(newdata, function(i, item) {
							var gid = newdata[i].glid;
							var name = newdata[i].propertyname;
							var propertySetName = newdata[i].propertySetName;
							var propertyTypeName = newdata[i].propertyTypeName;
							var externalId = newdata[i].externalId;
							var val = newdata[i].provalue;
							var groupname = newdata[i].groupname;
							option += "<ul>" + "<li>" + name + ":</li>" + "<li class=\"text-right pull-right\">" + val + "</li>" + "</ul>"

						});
					} else {
						option = option + "<ul><li colspan=\"2\">未找到相关属性！</li></ul>";
					}

					jQuery(obj).html(option);
					onloadFun2(); //滚动条
				} else {
					var option = "<ul><li colspan=\"2\">未找到相关属性！</li></ul>";
					jQuery(obj).html(option);
				}
				$.mask_close('#myTabContent'); //关闭loading
			})

		}
		function i_checkbox_toggle(ele, actionName) {
			var checobox = $(ele).parent("li").children("i.i_tree_checkbox");
			var checoboxAll = $(ele).parent("li").find("i.i_tree_checkbox");
			var treeLeave = $(ele).parent("li").children("span.tree_leave");
			var extid = $(ele).attr("att_val");
			var valtype = $(ele).attr("att_type");
			var valfilename = $(ele).attr("att_filename");
			var mid = $(ele).attr("mid");
			var glid = $(ele).attr("id");
			//切换选中状态
			if ($(checobox).hasClass("i_tree_checked")) {
				$(checobox).removeClass("i_tree_checked")
				$(checoboxAll).removeClass("i_tree_checked")
				// if (valtype == 1) {
				$.get("${pageContext.request.contextPath}/Ajax/" + actionName + "?extid=" + extid + "&glid=" + glid + "&filename=" + valfilename, function(dataextid) {
					console.log("invoked " + actionName);
					//var newdata = eval("(" + dataextid + ")");
					var arrstr = dataextid.split('#');
					for (var i = 0; i < arrstr.length; i++) {
						SetActorVisible(arrstr[i], false);
					}
				});

				//} else {
				//   
				//SetActorVisible(extid, false);
				//}

			} else {
				$(checobox).addClass("i_tree_checked")
				$(checoboxAll).addClass("i_tree_checked")
				//if (valtype == 1) {
				$.get("${pageContext.request.contextPath}/Ajax/" + actionName + "?extid=" + extid + "&glid=" + glid + "&filename=" + valfilename, function(dataextid) {
					console.log("invoked " + actionName);
					//var newdata = eval("(" + dataextid + ")");
					var arrstr = dataextid.split('#');
					for (var i = 0; i < arrstr.length; i++) {
						SetActorVisible(arrstr[i], true);
					}
				});
				//} else {
				//    SetActorVisible(extid, true);
				// }
			}
		}

		function detailshow(id, filename) {
			layer.load();
			$.get("${pageContext.request.contextPath}/Ajax/GetPropertyDetails?gid='" + id + "'&filename=" + filename, function(data) {
				console.log("invoked GetPropertyDetails");
				var newdata = data; // eval("(" + data + ")");
				var obj = document.getElementById("attrprop");
				var option = "<table><tbody>";
				var groupstr = "";
				jQuery.each(newdata, function(i, item) {
					var gid = newdata[i].Glid;
					var Mid = newdata[i].Mid;
					var name = newdata[i].Name;
					var val = newdata[i].Value;
					var groupname = newdata[i].groupname;
					var tips = "[" + groupname + "]<br/>" + name + "：<br/>" + val;
					if (groupname == groupstr) {
						option = option + "<tr title='" + tips + "'><td>" + name + "</td><td>" + val + "</td></tr>";
					} else {
						option = option + "<th colspan=\"2\">" + groupname + "</th>";
						option = option + "<tr title='" + tips + "'><td>" + name + "</td><td>" + val + "</td></tr>";
						groupstr = groupname;
					}
				});
				option = option + "</tbody></table>";
				layer.closeAll();
				jQuery(obj).html(option);
				onloadFun(); //滚动条
			})

		}
		//获取URL参数
		function GetUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return decodeURI(r[2]);
			return null;
		}

		function FnaddModel() {
			var MileageID = GetUrlParam("MileageID");
			layer_show1('模型上传', '${pageContext.request.contextPath}/UploadModel/AddModel', 514, 1200, true, true, 2);
		}
		//layer_show(false, "/User/Showtips", 600, 500);
	</script>
</body>

</html>